/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;

init(config: OpenApi.Config){
  super(config);
  @endpointRule = 'central';
  
@endpointMap = {
    cn-hangzhou = 'quickbi-public-share.aliyuncs.com',
    cn-hongkong = 'quickbi-public-share.aliyuncs.com',
    ap-southeast-1 = 'quickbi-public-share.aliyuncs.com',
    ap-southeast-3 = 'quickbi-public-share.aliyuncs.com',
    eu-central-1 = 'quickbi-public-share.aliyuncs.com',
  };

  checkConfig(config);
  @endpoint = getEndpoint('quickbi-public', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }

  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}
model CheckReadableRequest {
  worksId?: string(name='WorksId'),
  userId?: string(name='UserId'),
}

model CheckReadableResponseBody = {
  requestId?: string(name='RequestId'),
  success?: boolean(name='Success'),
  result?: boolean(name='Result'),
}

model CheckReadableResponse = {
  headers: map[string]string(name='headers'),
  body: CheckReadableResponseBody(name='body'),
}

async function checkReadableWithOptions(request: CheckReadableRequest, runtime: Util.RuntimeOptions): CheckReadableResponse {
  Util.validateModel(request);
  var query = {};
  query["WorksId"] = request.worksId;
  query["UserId"] = request.userId;
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = Util.toMap(request),
  };
  var params = new OpenApi.Params{
    action = 'CheckReadable',
    version = '2020-08-07',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function checkReadable(request: CheckReadableRequest): CheckReadableResponse {
  var runtime = new Util.RuntimeOptions{};
  return checkReadableWithOptions(request, runtime);
}

model QueryEmbeddedInfoResponseBody = {
  requestId?: string(name='RequestId'),
  success?: boolean(name='Success'),
  result?: {
    embeddedCount?: int32(name='EmbeddedCount'),
    maxCount?: int32(name='MaxCount'),
    detail?: {
      report?: int32(name='Report'),
      dashboardOfflineQuery?: int32(name='DashboardOfflineQuery'),
      page?: int32(name='Page'),
    }(name='Detail'),
  }(name='Result'),
}

model QueryEmbeddedInfoResponse = {
  headers: map[string]string(name='headers'),
  body: QueryEmbeddedInfoResponseBody(name='body'),
}

async function queryEmbeddedInfoWithOptions(runtime: Util.RuntimeOptions): QueryEmbeddedInfoResponse {
  var req = new OpenApi.OpenApiRequest{};
  var params = new OpenApi.Params{
    action = 'QueryEmbeddedInfo',
    version = '2020-08-07',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function queryEmbeddedInfo(): QueryEmbeddedInfoResponse {
  var runtime = new Util.RuntimeOptions{};
  return queryEmbeddedInfoWithOptions(runtime);
}

model QueryEmbeddedStausRequest {
  worksId?: string(name='WorksId'),
}

model QueryEmbeddedStausResponseBody = {
  requestId?: string(name='RequestId'),
  success?: boolean(name='Success'),
  result?: boolean(name='Result'),
}

model QueryEmbeddedStausResponse = {
  headers: map[string]string(name='headers'),
  body: QueryEmbeddedStausResponseBody(name='body'),
}

async function queryEmbeddedStausWithOptions(request: QueryEmbeddedStausRequest, runtime: Util.RuntimeOptions): QueryEmbeddedStausResponse {
  Util.validateModel(request);
  var query = {};
  query["WorksId"] = request.worksId;
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = Util.toMap(request),
  };
  var params = new OpenApi.Params{
    action = 'QueryEmbeddedStaus',
    version = '2020-08-07',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function queryEmbeddedStaus(request: QueryEmbeddedStausRequest): QueryEmbeddedStausResponse {
  var runtime = new Util.RuntimeOptions{};
  return queryEmbeddedStausWithOptions(request, runtime);
}

model QueryReadableResourcesListByUserIdRequest {
  userId?: string(name='UserId'),
}

model QueryReadableResourcesListByUserIdResponseBody = {
  requestId?: string(name='RequestId'),
  success?: boolean(name='Success'),
  result?: [ 
    {
      thirdPartAuthFlag?: int32(name='ThirdPartAuthFlag'),
      status?: int32(name='Status'),
      worksId?: string(name='WorksId'),
      createTime?: string(name='CreateTime'),
      workType?: string(name='WorkType'),
      ownerName?: string(name='OwnerName'),
      workspaceName?: string(name='WorkspaceName'),
      ownerId?: string(name='OwnerId'),
      modifyName?: string(name='ModifyName'),
      workspaceId?: string(name='WorkspaceId'),
      securityLevel?: string(name='SecurityLevel'),
      description?: string(name='Description'),
      workName?: string(name='WorkName'),
      directory?: {
        pathName?: string(name='PathName'),
        pathId?: string(name='PathId'),
        name?: string(name='Name'),
        id?: string(name='Id'),
      }(name='Directory'),
      modifyTime?: string(name='ModifyTime'),
    }
  ](name='Result'),
}

model QueryReadableResourcesListByUserIdResponse = {
  headers: map[string]string(name='headers'),
  body: QueryReadableResourcesListByUserIdResponseBody(name='body'),
}

async function queryReadableResourcesListByUserIdWithOptions(request: QueryReadableResourcesListByUserIdRequest, runtime: Util.RuntimeOptions): QueryReadableResourcesListByUserIdResponse {
  Util.validateModel(request);
  var query = {};
  query["UserId"] = request.userId;
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = Util.toMap(request),
  };
  var params = new OpenApi.Params{
    action = 'QueryReadableResourcesListByUserId',
    version = '2020-08-07',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function queryReadableResourcesListByUserId(request: QueryReadableResourcesListByUserIdRequest): QueryReadableResourcesListByUserIdResponse {
  var runtime = new Util.RuntimeOptions{};
  return queryReadableResourcesListByUserIdWithOptions(request, runtime);
}

model QueryWorksByOrganizationRequest {
  worksType?: string(name='WorksType'),
  status?: int32(name='Status'),
  thirdPartAuthFlag?: int32(name='ThirdPartAuthFlag'),
  pageNum?: int32(name='PageNum'),
  pageSize?: int32(name='PageSize'),
}

model QueryWorksByOrganizationResponseBody = {
  requestId?: string(name='RequestId'),
  success?: boolean(name='Success'),
  result?: {
    pageNum?: int32(name='PageNum'),
    data?: [ 
      {
        status?: int32(name='Status'),
        gmtModify?: string(name='GmtModify'),
        auth3rdFlag?: int32(name='Auth3rdFlag'),
        worksId?: string(name='WorksId'),
        workType?: string(name='WorkType'),
        ownerName?: string(name='OwnerName'),
        workspaceName?: string(name='WorkspaceName'),
        ownerId?: string(name='OwnerId'),
        modifyName?: string(name='ModifyName'),
        workspaceId?: string(name='WorkspaceId'),
        securityLevel?: string(name='SecurityLevel'),
        description?: string(name='Description'),
        workName?: string(name='WorkName'),
        gmtCreate?: string(name='GmtCreate'),
        directory?: {
          pathName?: string(name='PathName'),
          pathId?: string(name='PathId'),
          name?: string(name='Name'),
          id?: string(name='Id'),
        }(name='Directory'),
      }
    ](name='Data'),
    totalPages?: int32(name='TotalPages'),
    pageSize?: int32(name='PageSize'),
    totalNum?: int32(name='TotalNum'),
  }(name='Result'),
}

model QueryWorksByOrganizationResponse = {
  headers: map[string]string(name='headers'),
  body: QueryWorksByOrganizationResponseBody(name='body'),
}

async function queryWorksByOrganizationWithOptions(request: QueryWorksByOrganizationRequest, runtime: Util.RuntimeOptions): QueryWorksByOrganizationResponse {
  Util.validateModel(request);
  var query = {};
  query["WorksType"] = request.worksType;
  query["Status"] = request.status;
  query["ThirdPartAuthFlag"] = request.thirdPartAuthFlag;
  query["PageNum"] = request.pageNum;
  query["PageSize"] = request.pageSize;
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = Util.toMap(request),
  };
  var params = new OpenApi.Params{
    action = 'QueryWorksByOrganization',
    version = '2020-08-07',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function queryWorksByOrganization(request: QueryWorksByOrganizationRequest): QueryWorksByOrganizationResponse {
  var runtime = new Util.RuntimeOptions{};
  return queryWorksByOrganizationWithOptions(request, runtime);
}

model QueryWorksByWorkspaceRequest {
  workspaceId?: string(name='WorkspaceId'),
  worksType?: string(name='WorksType'),
  status?: int32(name='Status'),
  thirdPartAuthFlag?: int32(name='ThirdPartAuthFlag'),
  pageNum?: int32(name='PageNum'),
  pageSize?: int32(name='PageSize'),
}

model QueryWorksByWorkspaceResponseBody = {
  requestId?: string(name='RequestId'),
  success?: boolean(name='Success'),
  result?: {
    pageNum?: int32(name='PageNum'),
    data?: [ 
      {
        status?: int32(name='Status'),
        auth3rdFlag?: int32(name='Auth3rdFlag'),
        gmtModify?: string(name='GmtModify'),
        worksId?: string(name='WorksId'),
        workType?: string(name='WorkType'),
        ownerName?: string(name='OwnerName'),
        workspaceName?: string(name='WorkspaceName'),
        ownerId?: string(name='OwnerId'),
        modifyName?: string(name='ModifyName'),
        workspaceId?: string(name='WorkspaceId'),
        securityLevel?: string(name='SecurityLevel'),
        description?: string(name='Description'),
        workName?: string(name='WorkName'),
        gmtCreate?: string(name='GmtCreate'),
        directory?: {
          pathName?: string(name='PathName'),
          pathId?: string(name='PathId'),
          name?: string(name='Name'),
          id?: string(name='Id'),
        }(name='Directory'),
      }
    ](name='Data'),
    totalPages?: int32(name='TotalPages'),
    pageSize?: int32(name='PageSize'),
    totalNum?: int32(name='TotalNum'),
  }(name='Result'),
}

model QueryWorksByWorkspaceResponse = {
  headers: map[string]string(name='headers'),
  body: QueryWorksByWorkspaceResponseBody(name='body'),
}

async function queryWorksByWorkspaceWithOptions(request: QueryWorksByWorkspaceRequest, runtime: Util.RuntimeOptions): QueryWorksByWorkspaceResponse {
  Util.validateModel(request);
  var query = {};
  query["WorkspaceId"] = request.workspaceId;
  query["WorksType"] = request.worksType;
  query["Status"] = request.status;
  query["ThirdPartAuthFlag"] = request.thirdPartAuthFlag;
  query["PageNum"] = request.pageNum;
  query["PageSize"] = request.pageSize;
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = Util.toMap(request),
  };
  var params = new OpenApi.Params{
    action = 'QueryWorksByWorkspace',
    version = '2020-08-07',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function queryWorksByWorkspace(request: QueryWorksByWorkspaceRequest): QueryWorksByWorkspaceResponse {
  var runtime = new Util.RuntimeOptions{};
  return queryWorksByWorkspaceWithOptions(request, runtime);
}

model UpdateEmbeddedStatusRequest {
  worksId?: string(name='WorksId'),
  thirdPartAuthFlag?: boolean(name='ThirdPartAuthFlag'),
}

model UpdateEmbeddedStatusResponseBody = {
  requestId?: string(name='RequestId'),
  success?: boolean(name='Success'),
  result?: int32(name='Result'),
}

model UpdateEmbeddedStatusResponse = {
  headers: map[string]string(name='headers'),
  body: UpdateEmbeddedStatusResponseBody(name='body'),
}

async function updateEmbeddedStatusWithOptions(request: UpdateEmbeddedStatusRequest, runtime: Util.RuntimeOptions): UpdateEmbeddedStatusResponse {
  Util.validateModel(request);
  var query = {};
  query["WorksId"] = request.worksId;
  query["ThirdPartAuthFlag"] = request.thirdPartAuthFlag;
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = Util.toMap(request),
  };
  var params = new OpenApi.Params{
    action = 'UpdateEmbeddedStatus',
    version = '2020-08-07',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function updateEmbeddedStatus(request: UpdateEmbeddedStatusRequest): UpdateEmbeddedStatusResponse {
  var runtime = new Util.RuntimeOptions{};
  return updateEmbeddedStatusWithOptions(request, runtime);
}

